// ****************************************************************************
// *     Filename:  MyHit.hh
// *  Description:  
// *      License:  Geant4 Software License 
// *                http://geant4.cern.ch/license/LICENSE.html
// *       Author:  Tran Hoai Nam (nam), nam@kuno-g.phys.sci.osaka-u.ac.jp
// * Organization:  Osaka University
// *      Created:  2012-09-14 12:57:35
// ****************************************************************************
#ifndef MYHIT_QUBW2A24
#define MYHIT_QUBW2A24

#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4THitsCollection.hh"
#include "G4ParticleDefinition.hh"
#include "G4VHit.hh"

class MyHit : public G4VHit {
	public:
		enum MyHitType {
			CaloHit,
			TrackerHit
		};
	public:
		MyHit ();
		~MyHit ();
		const MyHit& operator = (const MyHit&);
		G4int operator == (const MyHit&) const;

		inline void *operator new(size_t);
		inline void operator delete(void *aHit);
		virtual void Draw();
		virtual void Print();

	private:
		MyHitType fHitType;
		//For calo-type hit
		G4double  fedep;
		G4String	fDetName;
		G4int			fCopyNo;
		//For tracker-type hit
		G4bool		fPriStopFlag;//is primary and stopped
		G4ThreeVector	fStopPoint;
		G4double	fStopTime;

		G4bool		fNewFlag;	//is new particle
		G4ThreeVector	fNewPoint;
		G4double	fNewTime;
		G4String	fNewName;
		G4int			fNewPID; //PDG encoding
		G4double	fNewKE;
		G4int			fNewTrackID;

		G4int			fDirection;	//-1: exit, 1: enter, 0: init
		G4double	fTime;
		G4double	fKE;
		G4String	fName;
		G4int			fPID; //PDG encoding
		G4int			fTrackID;
		G4ThreeVector	fPos;

	public:
		void Set_HitType (MyHitType value) {fHitType = value;}
		MyHitType Get_HitType() { return fHitType;}

		void Set_edep (G4double value) {fedep = value;}
		G4double Get_edep() { return fedep;}
		void Set_DetName (G4String value) {fDetName = value;}
		G4String Get_DetName() { return fDetName;}
		void Set_CopyNo (G4int value) {fCopyNo = value;}
		G4int Get_CopyNo() { return fCopyNo;}

		void Set_PriStopFlag () {fPriStopFlag = true;}
		G4bool IsPriStopped() { return fPriStopFlag;}
		void Set_StopPoint (G4ThreeVector value) {fStopPoint = value;}
		G4ThreeVector Get_StopPoint() { return fStopPoint;}
		void Set_StopTime (G4double value) {fStopTime = value;}
		G4double Get_StopTime() { return fStopTime;}

		void Set_NewFlag () {fNewFlag = true;}
		G4bool IsNew() { return fNewFlag;}
		void Set_NewPoint (G4ThreeVector value) {fNewPoint = value;}
		G4ThreeVector Get_NewPoint() { return fNewPoint;}
		void Set_NewTime (G4double value) {fNewTime = value;}
		G4double Get_NewTime() { return fNewTime;}
		void Set_NewName (G4String value) {fNewName = value;}
		G4String Get_NewName() { return fNewName;}
		void Set_NewPID (G4int value) {fNewPID = value;}
		G4int Get_NewPID() { return fNewPID;}
		void Set_NewKE (G4double value) {fNewKE = value;}
		G4double Get_NewKE() { return fNewKE;}
		void Set_NewTrackID (G4int value) {fNewTrackID = value;}
		G4int Get_NewTrackID() { return fNewTrackID;}

		void Set_Direction (G4int value) {fDirection = value;}
		G4int Get_Direction() { return fDirection;}
		void Set_Time (G4double value) {fTime = value;}
		G4double Get_Time() { return fTime;}
		void Set_KE (G4double value) {fKE = value;}
		G4double Get_KE() { return fKE;}
		void Set_Name (G4String value) {fName = value;}
		G4String Get_Name() { return fName;}
		void Set_PID (G4int value) {fPID = value;}
		G4int Get_PID() { return fPID;}
		void Set_TrackID (G4int value) {fTrackID = value;}
		G4int Get_TrackID() { return fTrackID;}
		void Set_Pos (G4ThreeVector value) {fPos = value;}
		G4ThreeVector Get_Pos() { return fPos;}
};

typedef G4THitsCollection<MyHit> MyHitsCollection;

extern G4Allocator<MyHit> MyHitAllocator;

inline void* MyHit::operator new(size_t)
{
	void* aHit;
	aHit = (void*)MyHitAllocator.MallocSingle();
	return aHit;
}

inline void MyHit::operator delete(void* aHit)
{
	MyHitAllocator.FreeSingle((MyHit*) aHit);
}

#endif /* end of include guard: MYHIT_QUBW2A24 */
